/*
 * @Project Name: spring-boot
 * @File Name: UeditorController
 * @Package Name: com.hhly.spring.boot.cache.controller
 * @Date: 2018/6/16 11:43
 * @Creator: linshixing-1199
 * @line------------------------------
 * @修改人:
 * @修改时间:
 * @修改内容:
 */

package com.sm.shoplook.controller.system;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author chenpy-1072
 * @desc UeditorController
 * @date 2018/6/16 11:43
 * @see
 */
@Controller
@RequestMapping("/ueditor")
public class UeditorController {

	@RequestMapping("/dispatch")
	public @ResponseBody String config(HttpServletRequest request, HttpServletResponse response) throws IOException {
		request.setCharacterEncoding("UTF-8");
		response.setHeader("Content-Type", "text/html");
		@SuppressWarnings("resource")
		ClassPathResource classPathResource = new ClassPathResource("static/public/ueditor/config.json");
		InputStream inputStream = classPathResource.getInputStream();
		return StreamUtils.copyToString(inputStream, Charset.forName("UTF-8"));
	}
}
